home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / lispref.info-28.z / lispref.info-28
Encoding:
GNU Info File  |  1998-05-21  |  46.2 KB  |  1,075 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo version
  2. 1.68 from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995 XEmacs Lisp
  12. Reference Manual (for 19.14 and 20.0) v3.1, March 1996 XEmacs Lisp
  13. Reference Manual (for 19.15 and 20.1, 20.2) v3.2, April, May 1997
  14.  
  15.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  16. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  17. Copyright (C) 1995, 1996 Ben Wing.
  18.  
  19.    Permission is granted to make and distribute verbatim copies of this
  20. manual provided the copyright notice and this permission notice are
  21. preserved on all copies.
  22.  
  23.    Permission is granted to copy and distribute modified versions of
  24. this manual under the conditions for verbatim copying, provided that the
  25. entire resulting derived work is distributed under the terms of a
  26. permission notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that this permission notice may be stated in a
  31. translation approved by the Foundation.
  32.  
  33.    Permission is granted to copy and distribute modified versions of
  34. this manual under the conditions for verbatim copying, provided also
  35. that the section entitled "GNU General Public License" is included
  36. exactly as in the original, and provided that the entire resulting
  37. derived work is distributed under the terms of a permission notice
  38. identical to this one.
  39.  
  40.    Permission is granted to copy and distribute translations of this
  41. manual into another language, under the above conditions for modified
  42. versions, except that the section entitled "GNU General Public License"
  43. may be included in a translation approved by the Free Software
  44. Foundation instead of in the original English.
  45.  
  46. 
  47. File: lispref.info,  Node: Insertion,  Next: Commands for Insertion,  Prev: Comparing Text,  Up: Text
  48.  
  49. Inserting Text
  50. ==============
  51.  
  52.    "Insertion" means adding new text to a buffer.  The inserted text
  53. goes at point--between the character before point and the character
  54. after point.
  55.  
  56.    Insertion relocates markers that point at positions after the
  57. insertion point, so that they stay with the surrounding text (*note
  58. Markers::.).  When a marker points at the place of insertion, insertion
  59. normally doesn't relocate the marker, so that it points to the
  60. beginning of the inserted text; however, certain special functions such
  61. as `insert-before-markers' relocate such markers to point after the
  62. inserted text.
  63.  
  64.    Some insertion functions leave point before the inserted text, while
  65. other functions leave it after.  We call the former insertion "after
  66. point" and the latter insertion "before point".
  67.  
  68.    If a string with non-`nil' extent data is inserted, the remembered
  69. extents will also be inserted.  *Note Duplicable Extents::.
  70.  
  71.    Insertion functions signal an error if the current buffer is
  72. read-only.
  73.  
  74.    These functions copy text characters from strings and buffers along
  75. with their properties.  The inserted characters have exactly the same
  76. properties as the characters they were copied from.  By contrast,
  77. characters specified as separate arguments, not part of a string or
  78. buffer, inherit their text properties from the neighboring text.
  79.  
  80.  - Function: insert &rest ARGS
  81.      This function inserts the strings and/or characters ARGS into the
  82.      current buffer, at point, moving point forward.  In other words, it
  83.      inserts the text before point.  An error is signaled unless all
  84.      ARGS are either strings or characters.  The value is `nil'.
  85.  
  86.  - Function: insert-before-markers &rest ARGS
  87.      This function inserts the strings and/or characters ARGS into the
  88.      current buffer, at point, moving point forward.  An error is
  89.      signaled unless all ARGS are either strings or characters.  The
  90.      value is `nil'.
  91.  
  92.      This function is unlike the other insertion functions in that it
  93.      relocates markers initially pointing at the insertion point, to
  94.      point after the inserted text.
  95.  
  96.  - Function: insert-string STRING &optional BUFFER
  97.      This function inserts STRING into BUFFER before point.  BUFFER
  98.      defaults to the current buffer if omitted.  This function is
  99.      chiefly useful if you want to insert a string in a buffer other
  100.      than the current one (otherwise you could just use `insert').
  101.  
  102.  - Function: insert-char CHARACTER COUNT &optional BUFFER
  103.      This function inserts COUNT instances of CHARACTER into BUFFER
  104.      before point.  COUNT must be a number, and CHARACTER must be a
  105.      character.  The value is `nil'.  If optional argument BUFFER is
  106.      `nil', the current buffer is assumed. (In FSF Emacs, the third
  107.      argument is called INHERIT and refers to text properties.)
  108.  
  109.  - Function: insert-buffer-substring FROM-BUFFER-OR-NAME &optional
  110.           START END
  111.      This function inserts a portion of buffer FROM-BUFFER-OR-NAME
  112.      (which must already exist) into the current buffer before point.
  113.      The text inserted is the region from START and END.  (These
  114.      arguments default to the beginning and end of the accessible
  115.      portion of that buffer.)  This function returns `nil'.
  116.  
  117.      In this example, the form is executed with buffer `bar' as the
  118.      current buffer.  We assume that buffer `bar' is initially empty.
  119.  
  120.           ---------- Buffer: foo ----------
  121.           We hold these truths to be self-evident, that all
  122.           ---------- Buffer: foo ----------
  123.           
  124.           (insert-buffer-substring "foo" 1 20)
  125.                => nil
  126.           
  127.           ---------- Buffer: bar ----------
  128.           We hold these truth-!-
  129.           ---------- Buffer: bar ----------
  130.  
  131. 
  132. File: lispref.info,  Node: Commands for Insertion,  Next: Deletion,  Prev: Insertion,  Up: Text
  133.  
  134. User-Level Insertion Commands
  135. =============================
  136.  
  137.    This section describes higher-level commands for inserting text,
  138. commands intended primarily for the user but useful also in Lisp
  139. programs.
  140.  
  141.  - Command: insert-buffer FROM-BUFFER-OR-NAME
  142.      This command inserts the entire contents of FROM-BUFFER-OR-NAME
  143.      (which must exist) into the current buffer after point.  It leaves
  144.      the mark after the inserted text.  The value is `nil'.
  145.  
  146.  - Command: self-insert-command COUNT
  147.      This command inserts the last character typed; it does so COUNT
  148.      times, before point, and returns `nil'.  Most printing characters
  149.      are bound to this command.  In routine use, `self-insert-command'
  150.      is the most frequently called function in XEmacs, but programs
  151.      rarely use it except to install it on a keymap.
  152.  
  153.      In an interactive call, COUNT is the numeric prefix argument.
  154.  
  155.      This command calls `auto-fill-function' whenever that is non-`nil'
  156.      and the character inserted is a space or a newline (*note Auto
  157.      Filling::.).
  158.  
  159.      This command performs abbrev expansion if Abbrev mode is enabled
  160.      and the inserted character does not have word-constituent syntax.
  161.      (*Note Abbrevs::, and *Note Syntax Class Table::.)
  162.  
  163.      This is also responsible for calling `blink-paren-function' when
  164.      the inserted character has close parenthesis syntax (*note
  165.      Blinking::.).
  166.  
  167.  - Command: newline &optional NUMBER-OF-NEWLINES
  168.      This command inserts newlines into the current buffer before point.
  169.      If NUMBER-OF-NEWLINES is supplied, that many newline characters
  170.      are inserted.
  171.  
  172.      This function calls `auto-fill-function' if the current column
  173.      number is greater than the value of `fill-column' and
  174.      NUMBER-OF-NEWLINES is `nil'.  Typically what `auto-fill-function'
  175.      does is insert a newline; thus, the overall result in this case is
  176.      to insert two newlines at different places: one at point, and
  177.      another earlier in the line.  `newline' does not auto-fill if
  178.      NUMBER-OF-NEWLINES is non-`nil'.
  179.  
  180.      This command indents to the left margin if that is not zero.
  181.      *Note Margins::.
  182.  
  183.      The value returned is `nil'.  In an interactive call, COUNT is the
  184.      numeric prefix argument.
  185.  
  186.  - Command: split-line
  187.      This command splits the current line, moving the portion of the
  188.      line after point down vertically so that it is on the next line
  189.      directly below where it was before.  Whitespace is inserted as
  190.      needed at the beginning of the lower line, using the `indent-to'
  191.      function.  `split-line' returns the position of point.
  192.  
  193.      Programs hardly ever use this function.
  194.  
  195.  - Variable: overwrite-mode
  196.      This variable controls whether overwrite mode is in effect: a
  197.      non-`nil' value enables the mode.  It is automatically made
  198.      buffer-local when set in any fashion.
  199.  
  200. 
  201. File: lispref.info,  Node: Deletion,  Next: User-Level Deletion,  Prev: Commands for Insertion,  Up: Text
  202.  
  203. Deleting Text
  204. =============
  205.  
  206.    Deletion means removing part of the text in a buffer, without saving
  207. it in the kill ring (*note The Kill Ring::.).  Deleted text can't be
  208. yanked, but can be reinserted using the undo mechanism (*note Undo::.).
  209. Some deletion functions do save text in the kill ring in some special
  210. cases.
  211.  
  212.    All of the deletion functions operate on the current buffer, and all
  213. return a value of `nil'.
  214.  
  215.  - Function: erase-buffer &optional BUFFER
  216.      This function deletes the entire text of BUFFER, leaving it empty.
  217.      If the buffer is read-only, it signals a `buffer-read-only'
  218.      error.  Otherwise, it deletes the text without asking for any
  219.      confirmation.  It returns `nil'.  BUFFER defaults to the current
  220.      buffer if omitted.
  221.  
  222.      Normally, deleting a large amount of text from a buffer inhibits
  223.      further auto-saving of that buffer "because it has shrunk".
  224.      However, `erase-buffer' does not do this, the idea being that the
  225.      future text is not really related to the former text, and its size
  226.      should not be compared with that of the former text.
  227.  
  228.  - Command: delete-region START END &optional BUFFER
  229.      This command deletes the text in BUFFER in the region defined by
  230.      START and END.  The value is `nil'.  If optional argument BUFFER
  231.      is `nil', the current buffer is assumed.
  232.  
  233.  - Command: delete-char COUNT &optional KILLP
  234.      This command deletes COUNT characters directly after point, or
  235.      before point if COUNT is negative.  If KILLP is non-`nil', then it
  236.      saves the deleted characters in the kill ring.
  237.  
  238.      In an interactive call, COUNT is the numeric prefix argument, and
  239.      KILLP is the unprocessed prefix argument.  Therefore, if a prefix
  240.      argument is supplied, the text is saved in the kill ring.  If no
  241.      prefix argument is supplied, then one character is deleted, but
  242.      not saved in the kill ring.
  243.  
  244.      The value returned is always `nil'.
  245.  
  246.  - Command: delete-backward-char COUNT &optional KILLP
  247.      This command deletes COUNT characters directly before point, or
  248.      after point if COUNT is negative.  If KILLP is non-`nil', then it
  249.      saves the deleted characters in the kill ring.
  250.  
  251.      In an interactive call, COUNT is the numeric prefix argument, and
  252.      KILLP is the unprocessed prefix argument.  Therefore, if a prefix
  253.      argument is supplied, the text is saved in the kill ring.  If no
  254.      prefix argument is supplied, then one character is deleted, but
  255.      not saved in the kill ring.
  256.  
  257.      The value returned is always `nil'.
  258.  
  259.  - Command: backward-delete-char-untabify COUNT &optional KILLP
  260.      This command deletes COUNT characters backward, changing tabs into
  261.      spaces.  When the next character to be deleted is a tab, it is
  262.      first replaced with the proper number of spaces to preserve
  263.      alignment and then one of those spaces is deleted instead of the
  264.      tab.  If KILLP is non-`nil', then the command saves the deleted
  265.      characters in the kill ring.
  266.  
  267.      Conversion of tabs to spaces happens only if COUNT is positive.
  268.      If it is negative, exactly -COUNT characters after point are
  269.      deleted.
  270.  
  271.      In an interactive call, COUNT is the numeric prefix argument, and
  272.      KILLP is the unprocessed prefix argument.  Therefore, if a prefix
  273.      argument is supplied, the text is saved in the kill ring.  If no
  274.      prefix argument is supplied, then one character is deleted, but
  275.      not saved in the kill ring.
  276.  
  277.      The value returned is always `nil'.
  278.  
  279. 
  280. File: lispref.info,  Node: User-Level Deletion,  Next: The Kill Ring,  Prev: Deletion,  Up: Text
  281.  
  282. User-Level Deletion Commands
  283. ============================
  284.  
  285.    This section describes higher-level commands for deleting text,
  286. commands intended primarily for the user but useful also in Lisp
  287. programs.
  288.  
  289.  - Command: delete-horizontal-space
  290.      This function deletes all spaces and tabs around point.  It returns
  291.      `nil'.
  292.  
  293.      In the following examples, we call `delete-horizontal-space' four
  294.      times, once on each line, with point between the second and third
  295.      characters on the line each time.
  296.  
  297.           ---------- Buffer: foo ----------
  298.           I -!-thought
  299.           I -!-     thought
  300.           We-!- thought
  301.           Yo-!-u thought
  302.           ---------- Buffer: foo ----------
  303.           
  304.           (delete-horizontal-space)   ; Four times.
  305.                => nil
  306.           
  307.           ---------- Buffer: foo ----------
  308.           Ithought
  309.           Ithought
  310.           Wethought
  311.           You thought
  312.           ---------- Buffer: foo ----------
  313.  
  314.  - Command: delete-indentation &optional JOIN-FOLLOWING-P
  315.      This function joins the line point is on to the previous line,
  316.      deleting any whitespace at the join and in some cases replacing it
  317.      with one space.  If JOIN-FOLLOWING-P is non-`nil',
  318.      `delete-indentation' joins this line to the following line
  319.      instead.  The value is `nil'.
  320.  
  321.      If there is a fill prefix, and the second of the lines being joined
  322.      starts with the prefix, then `delete-indentation' deletes the fill
  323.      prefix before joining the lines.  *Note Margins::.
  324.  
  325.      In the example below, point is located on the line starting
  326.      `events', and it makes no difference if there are trailing spaces
  327.      in the preceding line.
  328.  
  329.           ---------- Buffer: foo ----------
  330.           When in the course of human
  331.           -!-    events, it becomes necessary
  332.           ---------- Buffer: foo ----------
  333.           
  334.           (delete-indentation)
  335.                => nil
  336.           ---------- Buffer: foo ----------
  337.           When in the course of human-!- events, it becomes necessary
  338.           ---------- Buffer: foo ----------
  339.  
  340.      After the lines are joined, the function `fixup-whitespace' is
  341.      responsible for deciding whether to leave a space at the junction.
  342.  
  343.  - Function: fixup-whitespace
  344.      This function replaces all the white space surrounding point with
  345.      either one space or no space, according to the context.  It
  346.      returns `nil'.
  347.  
  348.      At the beginning or end of a line, the appropriate amount of space
  349.      is none.  Before a character with close parenthesis syntax, or
  350.      after a character with open parenthesis or expression-prefix
  351.      syntax, no space is also appropriate.  Otherwise, one space is
  352.      appropriate.  *Note Syntax Class Table::.
  353.  
  354.      In the example below, `fixup-whitespace' is called the first time
  355.      with point before the word `spaces' in the first line.  For the
  356.      second invocation, point is directly after the `('.
  357.  
  358.           ---------- Buffer: foo ----------
  359.           This has too many     -!-spaces
  360.           This has too many spaces at the start of (-!-   this list)
  361.           ---------- Buffer: foo ----------
  362.  
  363.           (fixup-whitespace)
  364.                => nil
  365.           (fixup-whitespace)
  366.                => nil
  367.  
  368.           ---------- Buffer: foo ----------
  369.           This has too many spaces
  370.           This has too many spaces at the start of (this list)
  371.           ---------- Buffer: foo ----------
  372.  
  373.  - Command: just-one-space
  374.      This command replaces any spaces and tabs around point with a
  375.      single space.  It returns `nil'.
  376.  
  377.  - Command: delete-blank-lines
  378.      This function deletes blank lines surrounding point.  If point is
  379.      on a blank line with one or more blank lines before or after it,
  380.      then all but one of them are deleted.  If point is on an isolated
  381.      blank line, then it is deleted.  If point is on a nonblank line,
  382.      the command deletes all blank lines following it.
  383.  
  384.      A blank line is defined as a line containing only tabs and spaces.
  385.  
  386.      `delete-blank-lines' returns `nil'.
  387.  
  388. 
  389. File: lispref.info,  Node: The Kill Ring,  Next: Undo,  Prev: User-Level Deletion,  Up: Text
  390.  
  391. The Kill Ring
  392. =============
  393.  
  394.    "Kill" functions delete text like the deletion functions, but save
  395. it so that the user can reinsert it by "yanking".  Most of these
  396. functions have `kill-' in their name.  By contrast, the functions whose
  397. names start with `delete-' normally do not save text for yanking
  398. (though they can still be undone); these are "deletion" functions.
  399.  
  400.    Most of the kill commands are primarily for interactive use, and are
  401. not described here.  What we do describe are the functions provided for
  402. use in writing such commands.  You can use these functions to write
  403. commands for killing text.  When you need to delete text for internal
  404. purposes within a Lisp function, you should normally use deletion
  405. functions, so as not to disturb the kill ring contents.  *Note
  406. Deletion::.
  407.  
  408.    Killed text is saved for later yanking in the "kill ring".  This is
  409. a list that holds a number of recent kills, not just the last text
  410. kill.  We call this a "ring" because yanking treats it as having
  411. elements in a cyclic order.  The list is kept in the variable
  412. `kill-ring', and can be operated on with the usual functions for lists;
  413. there are also specialized functions, described in this section, that
  414. treat it as a ring.
  415.  
  416.    Some people think this use of the word "kill" is unfortunate, since
  417. it refers to operations that specifically *do not* destroy the entities
  418. "killed".  This is in sharp contrast to ordinary life, in which death
  419. is permanent and "killed" entities do not come back to life.
  420. Therefore, other metaphors have been proposed.  For example, the term
  421. "cut ring" makes sense to people who, in pre-computer days, used
  422. scissors and paste to cut up and rearrange manuscripts.  However, it
  423. would be difficult to change the terminology now.
  424.  
  425. * Menu:
  426.  
  427. * Kill Ring Concepts::     What text looks like in the kill ring.
  428. * Kill Functions::         Functions that kill text.
  429. * Yank Commands::          Commands that access the kill ring.
  430. * Low-Level Kill Ring::       Functions and variables for kill ring access.
  431. * Internals of Kill Ring:: Variables that hold kill-ring data.
  432.  
  433. 
  434. File: lispref.info,  Node: Kill Ring Concepts,  Next: Kill Functions,  Up: The Kill Ring
  435.  
  436. Kill Ring Concepts
  437. ------------------
  438.  
  439.    The kill ring records killed text as strings in a list, most recent
  440. first.  A short kill ring, for example, might look like this:
  441.  
  442.      ("some text" "a different piece of text" "even older text")
  443.  
  444. When the list reaches `kill-ring-max' entries in length, adding a new
  445. entry automatically deletes the last entry.
  446.  
  447.    When kill commands are interwoven with other commands, each kill
  448. command makes a new entry in the kill ring.  Multiple kill commands in
  449. succession build up a single entry in the kill ring, which would be
  450. yanked as a unit; the second and subsequent consecutive kill commands
  451. add text to the entry made by the first one.
  452.  
  453.    For yanking, one entry in the kill ring is designated the "front" of
  454. the ring.  Some yank commands "rotate" the ring by designating a
  455. different element as the "front."  But this virtual rotation doesn't
  456. change the list itself--the most recent entry always comes first in the
  457. list.
  458.  
  459. 
  460. File: lispref.info,  Node: Kill Functions,  Next: Yank Commands,  Prev: Kill Ring Concepts,  Up: The Kill Ring
  461.  
  462. Functions for Killing
  463. ---------------------
  464.  
  465.    `kill-region' is the usual subroutine for killing text.  Any command
  466. that calls this function is a "kill command" (and should probably have
  467. `kill' in its name).  `kill-region' puts the newly killed text in a new
  468. element at the beginning of the kill ring or adds it to the most recent
  469. element.  It uses the `last-command' variable to determine whether the
  470. previous command was a kill command, and if so appends the killed text
  471. to the most recent entry.
  472.  
  473.  - Command: kill-region START END
  474.      This function kills the text in the region defined by START and
  475.      END.  The text is deleted but saved in the kill ring, along with
  476.      its text properties.  The value is always `nil'.
  477.  
  478.      In an interactive call, START and END are point and the mark.
  479.  
  480.      If the buffer is read-only, `kill-region' modifies the kill ring
  481.      just the same, then signals an error without modifying the buffer.
  482.      This is convenient because it lets the user use all the kill
  483.      commands to copy text into the kill ring from a read-only buffer.
  484.  
  485.  - Command: copy-region-as-kill START END
  486.      This command saves the region defined by START and END on the kill
  487.      ring (including text properties), but does not delete the text
  488.      from the buffer.  It returns `nil'.  It also indicates the extent
  489.      of the text copied by moving the cursor momentarily, or by
  490.      displaying a message in the echo area.
  491.  
  492.      The command does not set `this-command' to `kill-region', so a
  493.      subsequent kill command does not append to the same kill ring
  494.      entry.
  495.  
  496.      Don't call `copy-region-as-kill' in Lisp programs unless you aim to
  497.      support Emacs 18.  For Emacs 19, it is better to use `kill-new' or
  498.      `kill-append' instead.  *Note Low-Level Kill Ring::.
  499.  
  500. 
  501. File: lispref.info,  Node: Yank Commands,  Next: Low-Level Kill Ring,  Prev: Kill Functions,  Up: The Kill Ring
  502.  
  503. Functions for Yanking
  504. ---------------------
  505.  
  506.    "Yanking" means reinserting an entry of previously killed text from
  507. the kill ring.  The text properties are copied too.
  508.  
  509.  - Command: yank &optional ARG
  510.      This command inserts before point the text in the first entry in
  511.      the kill ring.  It positions the mark at the beginning of that
  512.      text, and point at the end.
  513.  
  514.      If ARG is a list (which occurs interactively when the user types
  515.      `C-u' with no digits), then `yank' inserts the text as described
  516.      above, but puts point before the yanked text and puts the mark
  517.      after it.
  518.  
  519.      If ARG is a number, then `yank' inserts the ARGth most recently
  520.      killed text--the ARGth element of the kill ring list.
  521.  
  522.      `yank' does not alter the contents of the kill ring or rotate it.
  523.      It returns `nil'.
  524.  
  525.  - Command: yank-pop ARG
  526.      This command replaces the just-yanked entry from the kill ring
  527.      with a different entry from the kill ring.
  528.  
  529.      This is allowed only immediately after a `yank' or another
  530.      `yank-pop'.  At such a time, the region contains text that was just
  531.      inserted by yanking.  `yank-pop' deletes that text and inserts in
  532.      its place a different piece of killed text.  It does not add the
  533.      deleted text to the kill ring, since it is already in the kill
  534.      ring somewhere.
  535.  
  536.      If ARG is `nil', then the replacement text is the previous element
  537.      of the kill ring.  If ARG is numeric, the replacement is the ARGth
  538.      previous kill.  If ARG is negative, a more recent kill is the
  539.      replacement.
  540.  
  541.      The sequence of kills in the kill ring wraps around, so that after
  542.      the oldest one comes the newest one, and before the newest one
  543.      goes the oldest.
  544.  
  545.      The value is always `nil'.
  546.  
  547. 
  548. File: lispref.info,  Node: Low-Level Kill Ring,  Next: Internals of Kill Ring,  Prev: Yank Commands,  Up: The Kill Ring
  549.  
  550. Low-Level Kill Ring
  551. -------------------
  552.  
  553.    These functions and variables provide access to the kill ring at a
  554. lower level, but still convenient for use in Lisp programs.  They take
  555. care of interaction with X Window selections.  They do not exist in
  556. Emacs version 18.
  557.  
  558.  - Function: current-kill N &optional DO-NOT-MOVE
  559.      The function `current-kill' rotates the yanking pointer which
  560.      designates the "front" of the kill ring by N places (from newer
  561.      kills to older ones), and returns the text at that place in the
  562.      ring.
  563.  
  564.      If the optional second argument DO-NOT-MOVE is non-`nil', then
  565.      `current-kill' doesn't alter the yanking pointer; it just returns
  566.      the Nth kill, counting from the current yanking pointer.
  567.  
  568.      If N is zero, indicating a request for the latest kill,
  569.      `current-kill' calls the value of `interprogram-paste-function'
  570.      (documented below) before consulting the kill ring.
  571.  
  572.  - Function: kill-new STRING
  573.      This function puts the text STRING into the kill ring as a new
  574.      entry at the front of the ring.  It discards the oldest entry if
  575.      appropriate.  It also invokes the value of
  576.      `interprogram-cut-function' (see below).
  577.  
  578.  - Function: kill-append STRING BEFORE-P
  579.      This function appends the text STRING to the first entry in the
  580.      kill ring.  Normally STRING goes at the end of the entry, but if
  581.      BEFORE-P is non-`nil', it goes at the beginning.  This function
  582.      also invokes the value of `interprogram-cut-function' (see below).
  583.  
  584.  - Variable: interprogram-paste-function
  585.      This variable provides a way of transferring killed text from other
  586.      programs, when you are using a window system.  Its value should be
  587.      `nil' or a function of no arguments.
  588.  
  589.      If the value is a function, `current-kill' calls it to get the
  590.      "most recent kill".  If the function returns a non-`nil' value,
  591.      then that value is used as the "most recent kill".  If it returns
  592.      `nil', then the first element of `kill-ring' is used.
  593.  
  594.      The normal use of this hook is to get the X server's primary
  595.      selection as the most recent kill, even if the selection belongs
  596.      to another X client.  *Note X Selections::.
  597.  
  598.  - Variable: interprogram-cut-function
  599.      This variable provides a way of communicating killed text to other
  600.      programs, when you are using a window system.  Its value should be
  601.      `nil' or a function of one argument.
  602.  
  603.      If the value is a function, `kill-new' and `kill-append' call it
  604.      with the new first element of the kill ring as an argument.
  605.  
  606.      The normal use of this hook is to set the X server's primary
  607.      selection to the newly killed text.
  608.  
  609. 
  610. File: lispref.info,  Node: Internals of Kill Ring,  Prev: Low-Level Kill Ring,  Up: The Kill Ring
  611.  
  612. Internals of the Kill Ring
  613. --------------------------
  614.  
  615.    The variable `kill-ring' holds the kill ring contents, in the form
  616. of a list of strings.  The most recent kill is always at the front of
  617. the list.
  618.  
  619.    The `kill-ring-yank-pointer' variable points to a link in the kill
  620. ring list, whose CAR is the text to yank next.  We say it identifies
  621. the "front" of the ring.  Moving `kill-ring-yank-pointer' to a
  622. different link is called "rotating the kill ring".  We call the kill
  623. ring a "ring" because the functions that move the yank pointer wrap
  624. around from the end of the list to the beginning, or vice-versa.
  625. Rotation of the kill ring is virtual; it does not change the value of
  626. `kill-ring'.
  627.  
  628.    Both `kill-ring' and `kill-ring-yank-pointer' are Lisp variables
  629. whose values are normally lists.  The word "pointer" in the name of the
  630. `kill-ring-yank-pointer' indicates that the variable's purpose is to
  631. identify one element of the list for use by the next yank command.
  632.  
  633.    The value of `kill-ring-yank-pointer' is always `eq' to one of the
  634. links in the kill ring list.  The element it identifies is the CAR of
  635. that link.  Kill commands, which change the kill ring, also set this
  636. variable to the value of `kill-ring'.  The effect is to rotate the ring
  637. so that the newly killed text is at the front.
  638.  
  639.    Here is a diagram that shows the variable `kill-ring-yank-pointer'
  640. pointing to the second entry in the kill ring `("some text" "a
  641. different piece of text" "yet older text")'.
  642.  
  643.      kill-ring       kill-ring-yank-pointer
  644.        |               |
  645.        |     ___ ___    --->  ___ ___      ___ ___
  646.         --> |___|___|------> |___|___|--> |___|___|--> nil
  647.               |                |            |
  648.               |                |            |
  649.               |                |             -->"yet older text"
  650.               |                |
  651.               |                 --> "a different piece of text"
  652.               |
  653.                --> "some text"
  654.  
  655. This state of affairs might occur after `C-y' (`yank') immediately
  656. followed by `M-y' (`yank-pop').
  657.  
  658.  - Variable: kill-ring
  659.      This variable holds the list of killed text sequences, most
  660.      recently killed first.
  661.  
  662.  - Variable: kill-ring-yank-pointer
  663.      This variable's value indicates which element of the kill ring is
  664.      at the "front" of the ring for yanking.  More precisely, the value
  665.      is a tail of the value of `kill-ring', and its CAR is the kill
  666.      string that `C-y' should yank.
  667.  
  668.  - User Option: kill-ring-max
  669.      The value of this variable is the maximum length to which the kill
  670.      ring can grow, before elements are thrown away at the end.  The
  671.      default value for `kill-ring-max' is 30.
  672.  
  673. 
  674. File: lispref.info,  Node: Undo,  Next: Maintaining Undo,  Prev: The Kill Ring,  Up: Text
  675.  
  676. Undo
  677. ====
  678.  
  679.    Most buffers have an "undo list", which records all changes made to
  680. the buffer's text so that they can be undone.  (The buffers that don't
  681. have one are usually special-purpose buffers for which XEmacs assumes
  682. that undoing is not useful.)  All the primitives that modify the text
  683. in the buffer automatically add elements to the front of the undo list,
  684. which is in the variable `buffer-undo-list'.
  685.  
  686.  - Variable: buffer-undo-list
  687.      This variable's value is the undo list of the current buffer.  A
  688.      value of `t' disables the recording of undo information.
  689.  
  690.    Here are the kinds of elements an undo list can have:
  691.  
  692. `INTEGER'
  693.      This kind of element records a previous value of point.  Ordinary
  694.      cursor motion does not get any sort of undo record, but deletion
  695.      commands use these entries to record where point was before the
  696.      command.
  697.  
  698. `(BEG . END)'
  699.      This kind of element indicates how to delete text that was
  700.      inserted.  Upon insertion, the text occupied the range BEG-END in
  701.      the buffer.
  702.  
  703. `(TEXT . POSITION)'
  704.      This kind of element indicates how to reinsert text that was
  705.      deleted.  The deleted text itself is the string TEXT.  The place to
  706.      reinsert it is `(abs POSITION)'.
  707.  
  708. `(t HIGH . LOW)'
  709.      This kind of element indicates that an unmodified buffer became
  710.      modified.  The elements HIGH and LOW are two integers, each
  711.      recording 16 bits of the visited file's modification time as of
  712.      when it was previously visited or saved.  `primitive-undo' uses
  713.      those values to determine whether to mark the buffer as unmodified
  714.      once again; it does so only if the file's modification time
  715.      matches those numbers.
  716.  
  717. `(nil PROPERTY VALUE BEG . END)'
  718.      This kind of element records a change in a text property.  Here's
  719.      how you might undo the change:
  720.  
  721.           (put-text-property BEG END PROPERTY VALUE)
  722.  
  723. `POSITION'
  724.      This element indicates where point was at an earlier time.
  725.      Undoing this element sets point to POSITION.  Deletion normally
  726.      creates an element of this kind as well as a reinsertion element.
  727.  
  728. `nil'
  729.      This element is a boundary.  The elements between two boundaries
  730.      are called a "change group"; normally, each change group
  731.      corresponds to one keyboard command, and undo commands normally
  732.      undo an entire group as a unit.
  733.  
  734.  - Function: undo-boundary
  735.      This function places a boundary element in the undo list.  The undo
  736.      command stops at such a boundary, and successive undo commands undo
  737.      to earlier and earlier boundaries.  This function returns `nil'.
  738.  
  739.      The editor command loop automatically creates an undo boundary
  740.      before each key sequence is executed.  Thus, each undo normally
  741.      undoes the effects of one command.  Self-inserting input
  742.      characters are an exception.  The command loop makes a boundary
  743.      for the first such character; the next 19 consecutive
  744.      self-inserting input characters do not make boundaries, and then
  745.      the 20th does, and so on as long as self-inserting characters
  746.      continue.
  747.  
  748.      All buffer modifications add a boundary whenever the previous
  749.      undoable change was made in some other buffer.  This way, a
  750.      command that modifies several buffers makes a boundary in each
  751.      buffer it changes.
  752.  
  753.      Calling this function explicitly is useful for splitting the
  754.      effects of a command into more than one unit.  For example,
  755.      `query-replace' calls `undo-boundary' after each replacement, so
  756.      that the user can undo individual replacements one by one.
  757.  
  758.  - Function: primitive-undo COUNT LIST
  759.      This is the basic function for undoing elements of an undo list.
  760.      It undoes the first COUNT elements of LIST, returning the rest of
  761.      LIST.  You could write this function in Lisp, but it is convenient
  762.      to have it in C.
  763.  
  764.      `primitive-undo' adds elements to the buffer's undo list when it
  765.      changes the buffer.  Undo commands avoid confusion by saving the
  766.      undo list value at the beginning of a sequence of undo operations.
  767.      Then the undo operations use and update the saved value.  The new
  768.      elements added by undoing are not part of this saved value, so
  769.      they don't interfere with continuing to undo.
  770.  
  771. 
  772. File: lispref.info,  Node: Maintaining Undo,  Next: Filling,  Prev: Undo,  Up: Text
  773.  
  774. Maintaining Undo Lists
  775. ======================
  776.  
  777.    This section describes how to enable and disable undo information for
  778. a given buffer.  It also explains how the undo list is truncated
  779. automatically so it doesn't get too big.
  780.  
  781.    Recording of undo information in a newly created buffer is normally
  782. enabled to start with; but if the buffer name starts with a space, the
  783. undo recording is initially disabled.  You can explicitly enable or
  784. disable undo recording with the following two functions, or by setting
  785. `buffer-undo-list' yourself.
  786.  
  787.  - Command: buffer-enable-undo &optional BUFFER-OR-NAME
  788.      This command enables recording undo information for buffer
  789.      BUFFER-OR-NAME, so that subsequent changes can be undone.  If no
  790.      argument is supplied, then the current buffer is used.  This
  791.      function does nothing if undo recording is already enabled in the
  792.      buffer.  It returns `nil'.
  793.  
  794.      In an interactive call, BUFFER-OR-NAME is the current buffer.  You
  795.      cannot specify any other buffer.
  796.  
  797.  - Function: buffer-disable-undo &optional BUFFER
  798.  - Function: buffer-flush-undo &optional BUFFER
  799.      This function discards the undo list of BUFFER, and disables
  800.      further recording of undo information.  As a result, it is no
  801.      longer possible to undo either previous changes or any subsequent
  802.      changes.  If the undo list of BUFFER is already disabled, this
  803.      function has no effect.
  804.  
  805.      This function returns `nil'.  It cannot be called interactively.
  806.  
  807.      The name `buffer-flush-undo' is not considered obsolete, but the
  808.      preferred name `buffer-disable-undo' is new as of Emacs versions
  809.      19.
  810.  
  811.    As editing continues, undo lists get longer and longer.  To prevent
  812. them from using up all available memory space, garbage collection trims
  813. them back to size limits you can set.  (For this purpose, the "size" of
  814. an undo list measures the cons cells that make up the list, plus the
  815. strings of deleted text.)  Two variables control the range of acceptable
  816. sizes: `undo-limit' and `undo-strong-limit'.
  817.  
  818.  - Variable: undo-limit
  819.      This is the soft limit for the acceptable size of an undo list.
  820.      The change group at which this size is exceeded is the last one
  821.      kept.
  822.  
  823.  - Variable: undo-strong-limit
  824.      This is the upper limit for the acceptable size of an undo list.
  825.      The change group at which this size is exceeded is discarded
  826.      itself (along with all older change groups).  There is one
  827.      exception: the very latest change group is never discarded no
  828.      matter how big it is.
  829.  
  830. 
  831. File: lispref.info,  Node: Filling,  Next: Margins,  Prev: Maintaining Undo,  Up: Text
  832.  
  833. Filling
  834. =======
  835.  
  836.    "Filling" means adjusting the lengths of lines (by moving the line
  837. breaks) so that they are nearly (but no greater than) a specified
  838. maximum width.  Additionally, lines can be "justified", which means
  839. inserting spaces to make the left and/or right margins line up
  840. precisely.  The width is controlled by the variable `fill-column'.  For
  841. ease of reading, lines should be no longer than 70 or so columns.
  842.  
  843.    You can use Auto Fill mode (*note Auto Filling::.) to fill text
  844. automatically as you insert it, but changes to existing text may leave
  845. it improperly filled.  Then you must fill the text explicitly.
  846.  
  847.    Most of the commands in this section return values that are not
  848. meaningful.  All the functions that do filling take note of the current
  849. left margin, current right margin, and current justification style
  850. (*note Margins::.).  If the current justification style is `none', the
  851. filling functions don't actually do anything.
  852.  
  853.    Several of the filling functions have an argument JUSTIFY.  If it is
  854. non-`nil', that requests some kind of justification.  It can be `left',
  855. `right', `full', or `center', to request a specific style of
  856. justification.  If it is `t', that means to use the current
  857. justification style for this part of the text (see
  858. `current-justification', below).
  859.  
  860.    When you call the filling functions interactively, using a prefix
  861. argument implies the value `full' for JUSTIFY.
  862.  
  863.  - Command: fill-paragraph JUSTIFY
  864.      This command fills the paragraph at or after point.  If JUSTIFY is
  865.      non-`nil', each line is justified as well.  It uses the ordinary
  866.      paragraph motion commands to find paragraph boundaries.  *Note
  867.      Paragraphs: (emacs)Paragraphs.
  868.  
  869.  - Command: fill-region START END &optional JUSTIFY
  870.      This command fills each of the paragraphs in the region from START
  871.      to END.  It justifies as well if JUSTIFY is non-`nil'.
  872.  
  873.      The variable `paragraph-separate' controls how to distinguish
  874.      paragraphs.  *Note Standard Regexps::.
  875.  
  876.  - Command: fill-individual-paragraphs START END &optional JUSTIFY
  877.           MAIL-FLAG
  878.      This command fills each paragraph in the region according to its
  879.      individual fill prefix.  Thus, if the lines of a paragraph were
  880.      indented with spaces, the filled paragraph will remain indented in
  881.      the same fashion.
  882.  
  883.      The first two arguments, START and END, are the beginning and end
  884.      of the region to be filled.  The third and fourth arguments,
  885.      JUSTIFY and MAIL-FLAG, are optional.  If JUSTIFY is non-`nil', the
  886.      paragraphs are justified as well as filled.  If MAIL-FLAG is
  887.      non-`nil', it means the function is operating on a mail message
  888.      and therefore should not fill the header lines.
  889.  
  890.      Ordinarily, `fill-individual-paragraphs' regards each change in
  891.      indentation as starting a new paragraph.  If
  892.      `fill-individual-varying-indent' is non-`nil', then only separator
  893.      lines separate paragraphs.  That mode can handle indented
  894.      paragraphs with additional indentation on the first line.
  895.  
  896.  - User Option: fill-individual-varying-indent
  897.      This variable alters the action of `fill-individual-paragraphs' as
  898.      described above.
  899.  
  900.  - Command: fill-region-as-paragraph START END &optional JUSTIFY
  901.      This command considers a region of text as a paragraph and fills
  902.      it.  If the region was made up of many paragraphs, the blank lines
  903.      between paragraphs are removed.  This function justifies as well
  904.      as filling when JUSTIFY is non-`nil'.
  905.  
  906.      In an interactive call, any prefix argument requests justification.
  907.  
  908.      In Adaptive Fill mode, which is enabled by default,
  909.      `fill-region-as-paragraph' on an indented paragraph when there is
  910.      no fill prefix uses the indentation of the second line of the
  911.      paragraph as the fill prefix.
  912.  
  913.  - Command: justify-current-line HOW EOP NOSQUEEZE
  914.      This command inserts spaces between the words of the current line
  915.      so that the line ends exactly at `fill-column'.  It returns `nil'.
  916.  
  917.      The argument HOW, if non-`nil' specifies explicitly the style of
  918.      justification.  It can be `left', `right', `full', `center', or
  919.      `none'.  If it is `t', that means to do follow specified
  920.      justification style (see `current-justification', below).  `nil'
  921.      means to do full justification.
  922.  
  923.      If EOP is non-`nil', that means do left-justification when
  924.      `current-justification' specifies full justification.  This is used
  925.      for the last line of a paragraph; even if the paragraph as a whole
  926.      is fully justified, the last line should not be.
  927.  
  928.      If NOSQUEEZE is non-`nil', that means do not change interior
  929.      whitespace.
  930.  
  931.  - User Option: default-justification
  932.      This variable's value specifies the style of justification to use
  933.      for text that doesn't specify a style with a text property.  The
  934.      possible values are `left', `right', `full', `center', or `none'.
  935.      The default value is `left'.
  936.  
  937.  - Function: current-justification
  938.      This function returns the proper justification style to use for
  939.      filling the text around point.
  940.  
  941.  - Variable: fill-paragraph-function
  942.      This variable provides a way for major modes to override the
  943.      filling of paragraphs.  If the value is non-`nil',
  944.      `fill-paragraph' calls this function to do the work.  If the
  945.      function returns a non-`nil' value, `fill-paragraph' assumes the
  946.      job is done, and immediately returns that value.
  947.  
  948.      The usual use of this feature is to fill comments in programming
  949.      language modes.  If the function needs to fill a paragraph in the
  950.      usual way, it can do so as follows:
  951.  
  952.           (let ((fill-paragraph-function nil))
  953.             (fill-paragraph arg))
  954.  
  955.  - Variable: use-hard-newlines
  956.      If this variable is non-`nil', the filling functions do not delete
  957.      newlines that have the `hard' text property.  These "hard
  958.      newlines" act as paragraph separators.
  959.  
  960. 
  961. File: lispref.info,  Node: Margins,  Next: Auto Filling,  Prev: Filling,  Up: Text
  962.  
  963. Margins for Filling
  964. ===================
  965.  
  966.  - User Option: fill-prefix
  967.      This variable specifies a string of text that appears at the
  968.      beginning of normal text lines and should be disregarded when
  969.      filling them.  Any line that fails to start with the fill prefix
  970.      is considered the start of a paragraph; so is any line that starts
  971.      with the fill prefix followed by additional whitespace.  Lines
  972.      that start with the fill prefix but no additional whitespace are
  973.      ordinary text lines that can be filled together.  The resulting
  974.      filled lines also start with the fill prefix.
  975.  
  976.      The fill prefix follows the left margin whitespace, if any.
  977.  
  978.  - User Option: fill-column
  979.      This buffer-local variable specifies the maximum width of filled
  980.      lines.  Its value should be an integer, which is a number of
  981.      columns.  All the filling, justification and centering commands
  982.      are affected by this variable, including Auto Fill mode (*note
  983.      Auto Filling::.).
  984.  
  985.      As a practical matter, if you are writing text for other people to
  986.      read, you should set `fill-column' to no more than 70.  Otherwise
  987.      the line will be too long for people to read comfortably, and this
  988.      can make the text seem clumsy.
  989.  
  990.  - Variable: default-fill-column
  991.      The value of this variable is the default value for `fill-column'
  992.      in buffers that do not override it.  This is the same as
  993.      `(default-value 'fill-column)'.
  994.  
  995.      The default value for `default-fill-column' is 70.
  996.  
  997.  - Command: set-left-margin FROM TO MARGIN
  998.      This sets the `left-margin' property on the text from FROM to TO
  999.      to the value MARGIN.  If Auto Fill mode is enabled, this command
  1000.      also refills the region to fit the new margin.
  1001.  
  1002.  - Command: set-right-margin FROM TO MARGIN
  1003.      This sets the `right-margin' property on the text from FROM to TO
  1004.      to the value MARGIN.  If Auto Fill mode is enabled, this command
  1005.      also refills the region to fit the new margin.
  1006.  
  1007.  - Function: current-left-margin
  1008.      This function returns the proper left margin value to use for
  1009.      filling the text around point.  The value is the sum of the
  1010.      `left-margin' property of the character at the start of the
  1011.      current line (or zero if none), and the value of the variable
  1012.      `left-margin'.
  1013.  
  1014.  - Function: current-fill-column
  1015.      This function returns the proper fill column value to use for
  1016.      filling the text around point.  The value is the value of the
  1017.      `fill-column' variable, minus the value of the `right-margin'
  1018.      property of the character after point.
  1019.  
  1020.  - Command: move-to-left-margin &optional N FORCE
  1021.      This function moves point to the left margin of the current line.
  1022.      The column moved to is determined by calling the function
  1023.      `current-left-margin'.  If the argument N is non-`nil',
  1024.      `move-to-left-margin' moves forward N-1 lines first.
  1025.  
  1026.      If FORCE is non-`nil', that says to fix the line's indentation if
  1027.      that doesn't match the left margin value.
  1028.  
  1029.  - Function: delete-to-left-margin FROM TO
  1030.      This function removes left margin indentation from the text
  1031.      between FROM and TO.  The amount of indentation to delete is
  1032.      determined by calling `current-left-margin'.  In no case does this
  1033.      function delete non-whitespace.
  1034.  
  1035.  - Function: indent-to-left-margin
  1036.      This is the default `indent-line-function', used in Fundamental
  1037.      mode, Text mode, etc.  Its effect is to adjust the indentation at
  1038.      the beginning of the current line to the value specified by the
  1039.      variable `left-margin'.  This may involve either inserting or
  1040.      deleting whitespace.
  1041.  
  1042.  - Variable: left-margin
  1043.      This variable specifies the base left margin column.  In
  1044.      Fundamental mode, <LFD> indents to this column.  This variable
  1045.      automatically becomes buffer-local when set in any fashion.
  1046.  
  1047. 
  1048. File: lispref.info,  Node: Auto Filling,  Next: Sorting,  Prev: Margins,  Up: Text
  1049.  
  1050. Auto Filling
  1051. ============
  1052.  
  1053.    Auto Fill mode is a minor mode that fills lines automatically as text
  1054. is inserted.  This section describes the hook used by Auto Fill mode.
  1055. For a description of functions that you can call explicitly to fill and
  1056. justify existing text, see *Note Filling::.
  1057.  
  1058.    Auto Fill mode also enables the functions that change the margins and
  1059. justification style to refill portions of the text.  *Note Margins::.
  1060.  
  1061.  - Variable: auto-fill-function
  1062.      The value of this variable should be a function (of no arguments)
  1063.      to be called after self-inserting a space or a newline.  It may be
  1064.      `nil', in which case nothing special is done in that case.
  1065.  
  1066.      The value of `auto-fill-function' is `do-auto-fill' when Auto-Fill
  1067.      mode is enabled.  That is a function whose sole purpose is to
  1068.      implement the usual strategy for breaking a line.
  1069.  
  1070.           In older Emacs versions, this variable was named
  1071.           `auto-fill-hook', but since it is not called with the
  1072.           standard convention for hooks, it was renamed to
  1073.           `auto-fill-function' in version 19.
  1074.  
  1075.